#!/usr/bin/env python
# -*- coding:utf-8 -*-

'file opeartion introduction'

__author__='zhaoxp'

import os

if __name__=='__main__':
	print 'import os'
	print 'OS name =',os.name
	#print 'os.uname() =',os.uname() #not work on 2.7.8
	print 'os.environ =',os.environ
	print "os.getenv('PATH') =",os.getenv('PATH')
	
	curpath=os.path.abspath('.')
	print "current path, os.path.abspath('.') =",curpath
	newpath=os.path.join(curpath,'newdir')
	print "os.path.join(curpath,'newdir') =",newpath
	os.mkdir(newpath)
	print "os.mkdir(newpath) ",newpath
	os.rmdir(newpath)
	print "os.rmdir(newpath) ",newpath
	s='d:\\temp\\test.txt'
	print 's =',s
	print "os.path.split(s) =",os.path.split(s)
	print "os.path.splitext(s) =",os.path.splitext(s)
	
	print 'os.rename'
	print "os.rename(s,s+'.bak') =",os.rename(s,s+'.bak')
	print "os.rename(s+'.bak',s) =",os.rename(s+'.bak',s)
	print "os.remove(s) = ..."
	#os.remove(s)
	
	print "[x for x in os.listdir('.') if not os.path.isdir(x)] =",[x for x in os.listdir('.') if not os.path.isdir(x)]
	print "[x for x in os.listdir('.') if os.path.isfile(x) and os.path.splitext(x)[1]=='.py'] =",[x for x in os.listdir('.') if os.path.isfile(x) and os.path.splitext(x)[1]=='.py']
	